<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>商家列表</title>
		<link rel="stylesheet" href="__OEM__/css/iconfont.css" />
		<link rel="stylesheet" href="__OEM__/css/css.css" />
	</head>
<style>
	.pagination{
		margin-top: 10px;
		float: right;
	}
	{if $Think.session.user_level==1}
	.empty {
	    top: 60px;
	}
	{else/}
	.empty {
	    top: 40px;
	}	
	{/if}
	
</style>
	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">
					<!--右侧内容-->
					<div class="rigtop">
						<span class="title">商家列表</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<!--{if $Think.session.user_level==3 && $Think.session.user_type==1}
						<div class="zizh_btnbox" style="top: -58px;right:30px">
							<button class="zizh_btn" type="button"><i class="iconfont icon-jia"></i>创建商户</button>
						</div>
						{/if}-->
						<div class="zizh_conbox" style="padding-top: 20px;">
							<!--选项卡内容开始-->
							<div class="huizcx_top">
								<div class="chax_rowbox2 clearfix">
									<form id="my_form" action="{:url('oem/accounts/agent')}" method="post">
										<div class="shxx_row clearfix">
											<div class="left">店铺名称：</div>
											<div class="right clearfix">
												<input type="text" name="agent_name" id="agent_name" value="{$agent_name}" placeholder="店铺名称" class="chax_input" />
											</div>
										</div>
										<div class="shxx_row chax_row clearfix">
											<div class="left">手机号码：</div>
											<div class="right clearfix">
												<input type="text" name="mobile" id="mobile" value="{$mobile}" placeholder="手机号码" class="chax_input" />
											</div>
										</div>
										<div class="shxx_row chax_row clearfix" >
											<div class="left">服务商：</div>
								            <div class="right clearfix">
												<div id="htselect">	
												<select name="ch_city" id="ch_city">
													<option value="">全部</option>
													{volist name="city" id="vo"}
														<option value="{$vo.id}">{$vo.user_name}</option>
													{/volist}
												</select>
												</div>
											</div>
										</div>
										<div class="shxx_row chax_row clearfix">
											<button type="submit" class="htcxbtn">查询</button>
										</div>
									</form>
								</div>							
								<div class="chax_conbox">
									<div class="chax_jiegbt clearfix">
										<div class="chax_jieg">总计：{$list->total();}家</div>
										<div class="chax_xzbtnbox">
											<a href="javascript:;" onclick="check()"><i class="iconfont icon-download"></i>商家下载</a>
										</div>
									</div>
									<div class="chax_jiegnr">
										<table class="zizh_table1 zizh_table2">
											<thead>
												<tr style="text-align: center;">
													<th width="200px">商家名称</th>
													<th width="100px">服务商</th>
													<th width="200px">手机号码</th>
													<th style="width: 5%;">余额</th>
													<th style="width: 5%;">鼓励金</th>
													<th style="width: 8%;">资质认证</th>
													<th style="width: 7%;">推广数</th>
													<th style="width: 8%;">创业股东</th>
													<th style="width: 5%;">状态</th>
													<th style="width: 10%;">创建时间</th>
													{if $Think.session.user_level==1}
													<th class="w_20" style="text-align: center;">操作</th>
													{else/}
													<th width="100px">操作</th>
													{/if}
												</tr>
											</thead>
											<tbody id="tbody">
												{volist name="list" id="vo" empty="$empty"}
												<tr>
													<td>{$vo.agent_name}</td>
													<td>{$vo.city_name}</td>
													<td>{$vo.mobile}</td>
													<td>
														<?php echo substr($vo['balance'],0,strlen($vo['balance'])-2)?>
													</td>
													<td>
														<?php echo substr($vo['score'],0,strlen($vo['score'])-2)?>
													</td>
													<td>{if $vo.is_state==1}<a href="{:url('index/qianyue_step5',['agent_id'=>$vo.id])}">已签约</a>
														{elseif $vo.is_state==2}
														未签约
														{else}
														<a href="{:url('index/qianyue_step5',['agent_id'=>$vo.id])}">未通过</a>
														{/if}</td>
													<td>{$vo.count?$vo.count : 0}</td>
													<td>{$vo.counts?$vo.counts : 0}</td>
													<td>
														{if $vo.status==1}
														正常
														{else/}
														冻结
														{/if}
													</td>
													<td>{$vo.add_time|substr=0,10}</td>													
													<td style="text-align: center;">
														<a onclick="show_agent('{$vo.id}')">详情</a>
														{if $Think.session.user_level==1}
															{if $vo.status == 1}
																<a href="javascript:;" onclick="caozuo('{$vo.id}','2')">开</a>
															{else/}
																<a href="javascript:;" onclick="caozuo('{$vo.id}','1')" class="green">关</a>
															{/if}
															
															{if $vo.is_huilu == 1}
																<a href="javascript:;" onclick="is_display('{$vo.id}','2')">不显示</a>
															{else}
																<a href="javascript:;" onclick="is_display('{$vo.id}','1')" class="green">显示</a>
															{/if}
														{/if}
													</td>												
												</tr>
												{/volist}
										</table>
									</div>
									{$list->render()}
								</div>
							</div>
						</div>

					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}

	</body>
	<script>
		$(".zizh_btn").click(function() {
			layer.open({
				type: 2,
				title: '添加商家',
				shadeClose: true,
				shade: 0.8,
				area: ['800px', '700px'],
				content: "{:url('accounts/add_agent')}"
			});
		})

		function show_agent(id) {
			var url = 'show_agent?id=' + id;
			layer.open({
				type: 2,
				title: '商家详情',
				shadeClose: true,
				shade: 0.8,
				area: ['500px', '500px'],
				content: [url]
			});
		}

		function check() {
			var agent_name = $('#agent_name').val();
			var mobile = $('#mobile').val();
			window.location.href = "/oem/accounts/agent_dcxml.html?agent_name=" + agent_name + "&mobile=" + mobile;
		}
	function upagent_huilv(id){
		var url='upagent_huilv?id='+id;
		layer.open({
		  type: 2,
		  title: '修改商家费率',
		  shadeClose: true,
		  shade: 0.8,
		  area: ['500px', '	220px'],
		  content:  [url]
		}); 
	}
	
	/*操作*/
	function caozuo(id,status) {
		var msg='';
		if(status==2){
			msg='冻结';
		}else{
			msg='激活';
		}
		layer.confirm('您确定要'+msg+'吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				url: "{:url('accounts/agent_status')}",
				data: {
					id:id,
					status:status
				},
				dataType: 'json',
				success: function(data) {
					layer.msg("成功", {
						icon: 1,
						time: 1000
					}, function() {
						location.href = "{:url('accounts/agent')}";
					});
				}
			})
		})
	}
	
	/*操作*/
	function is_display(id,status) {
		var msg='';
		if(status==2){
			msg='不在附近显示';
		}else{
			msg='附近显示';
		}
		layer.confirm('您确定要'+msg+'吗？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				url: "{:url('accounts/agent_display')}",
				data: {
					id:id,
					status:status
				},
				dataType: 'json',
				success: function(data) {
					layer.msg("成功", {
						icon: 1,
						time: 1000
					}, function() {
						location.href = "{:url('accounts/agent')}";
					});
				}
			})
		})
	}
	
	</script>

</html>